package tenants

import (
	"context"
	"product/authorization/serve/internal/svc"
	"product/authorization/serve/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type DeleteTenantLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

// 删除租户信息
func NewDeleteTenantLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteTenantLogic {
	return &DeleteTenantLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *DeleteTenantLogic) DeleteTenant(req *types.DeleteTenantReq) (resp *types.DeleteTenantResp, err error) {
	if req.ID <= 0 {
		return &types.DeleteTenantResp{
			Message: "参数错误",
			Ok:      false,
		}, nil
	}
	err = l.svcCtx.TenantModel.DeleteTenant(l.ctx, req.ID)
	if err != nil {
		return &types.DeleteTenantResp{
			Message: "删除失败",
			Ok:      false,
		}, nil
	}
	return &types.DeleteTenantResp{
		Message: "删除成功",
		Ok:      true,
	}, nil
}
